package stars;

import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import java.util.Scanner;

public class Solution {
	private static class Point {
		long x, y;
		int v;
		public Point(long x, long y, int v) {
			this.x = x;
			this.y = y;
			this.v = v;
		}
		private static int sumV(List<Point> p) {
			int s = 0;
			for(Point pi : p)
				s += pi.v;
			return s;
		}
	}
	private static class PointComparator implements Comparator<Point> {
		Point p;
		public PointComparator(Point p) {
			this.p = p;
		}
		@Override
		public int compare(Point p1, Point p2) {
			if(p1.x != p2.x)
				return p1.x > p2.x ? 1 : -1;
			if(p1.x <= p.x)
				return p1.y > p2.y ? 1 : (p1.y < p2.y ? -1 : 0);
			return p1.y > p2.y ? -1 : (p1.y < p2.y ? 1 : 0);
		}
	}
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		try {
			int N = in.nextInt();
			List<Point> p = new ArrayList<Point>();
			for(int n = 0; n < N; n++)
				p.add(new Point(in.nextLong(), in.nextLong(), in.nextInt()));
			
			// find lowest point index
			int l = 0;
			for(int i = 1; i < N; i++)
				if(p.get(i).y < p.get(l).y)
					l = i;
			
			int sumV = Point.sumV(p), minDiffV = sumV, minDiffSmallV = 0;
			
			// remove lowest point
			Point lp = p.remove(l);
			
			// sort the points left to right w.r.t. lowest point
			Collections.sort(p, new PointComparator(lp));
			
			Point p1 = lp, p2 = p.get(0);
			
			// calculate minDiff from p1
			int diffV = Math.abs(sumV - 2 * p1.v);
			if(diffV < minDiffV) {
				minDiffV = diffV;
				minDiffSmallV = Math.min(sumV - p1.v, p1.v);
			}
			
			// calculate minDiff from p2
			diffV = Math.abs(sumV - 2 * p2.v);
			if(diffV < minDiffV) {
				minDiffV = diffV;
				minDiffSmallV = Math.min(sumV - p2.v, p2.v);
			}
			
			for(int i = 1; i < p.size(); i++) {
				Point p3 = p.get(i);
				if((p2.x - p1.x) * (p3.y - p1.y) <= (p2.y - p1.y) * (p3.x - p1.x)) {
					// calculate minDiff from p3
					diffV = Math.abs(sumV - 2 * p3.v);
					if(diffV < minDiffV) {
						minDiffV = diffV;
						minDiffSmallV = Math.min(sumV - p3.v, p3.v);
					}
					p1 = p2;
					p2 = p3;
				}
			}
			
			// get back the lowest point
			p.add(lp);
			
			for(int i = 0; i < N; i++) {
				Point pi = p.get(i);
				for(int j = i + 1; j < N; j++) {
					Point pj = p.get(j);
					int v1 = 0, v2 = 0;
					for(int k = 0; k < N; k++) {
						Point pk = p.get(k);
						if((pk.y - pi.y) * (pj.x - pi.x) > (pj.y - pi.y) * (pk.x - pi.x))
							v1 += pk.v;
						else
							v2 += pk.v;
					}
					diffV = Math.abs(v2 - v1);
					if(diffV < minDiffV) {
						minDiffV = diffV;
						minDiffSmallV = Math.min(v1, v2);
					}
					v1 = 0;
					v2 = 0;
					for(int k = 0; k < N; k++) {
						Point pk = p.get(k);
						if((pk.y - pi.y) * (pj.x - pi.x) >= (pj.y - pi.y) * (pk.x - pi.x))
							v1 += pk.v;
						else
							v2 += pk.v;
					}
					diffV = Math.abs(v2 - v1);
					if(diffV < minDiffV) {
						minDiffV = diffV;
						minDiffSmallV = Math.min(v1, v2);
					}
				}
			}
			System.out.println(minDiffSmallV);
		} finally {
			in.close();
		}
	}
}
